package cn.elead.chaos.security.service.impl;

import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;

import cn.elead.chaos.security.SecurityUser;
import cn.elead.chaos.security.service.ISpringSecurityService;


public class SpringSecurityService implements ISpringSecurityService{

	
	/**
	 * 获取角色
	 * 
	 * @param userId
	 * @return
	 */
	@Override
	public Set<String> selectRoleKeys() {
		return selectRoleKeys("");
	}
	/**
	 * 获取角色
	 * 
	 * @param userId
	 * @return
	 */
	@Override
	public Set<String> selectRoleKeys(String userId) {
		return Arrays.asList("ADMIN").stream().collect(Collectors.toSet());
	}

	/**
	 * 获取资源权限
	 * 
	 * @param userId
	 * @return
	 */
	@Override
	public Set<String> selectPermsByUserId() {
		return selectPermsByUserId("");
	}
	/**
	 * 获取资源权限
	 * 
	 * @param userId
	 * @return
	 */
	@Override
	public Set<String> selectPermsByUserId(String userId) {
		//LoginUser user = getUser();
		 // 管理员拥有所有权限
        //if (user.isAdmin()) {
           // return Arrays.asList("*:*:*").stream().collect(Collectors.toSet());
        //}
		return Arrays.asList("system:user:list", "user:list", "user:get").stream().collect(Collectors.toSet());
	}

	/**
	 * 获取用户信息
	 * 
	 * @param token
	 * @return
	 */
	@Override
	public SecurityUser getUser() {
		SecurityUser user = new SecurityUser();
		user.setLoginName("test");
		return user;
	}
	
	
}
